package com.example.dragandview.frag;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.dragandview.R;

public class BottomFragment extends Fragment {
    @Override
    public View onCreateView( LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_bottom,container,false);
        TextView textView = view.findViewById(R.id.tv_text_bottom);
        view.findViewById(R.id.btn_fragment_bottom).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                textView.setText("ooooooooooooo");
            }
        });
        return view;
    }

    @Override
    public void onActivityCreated( Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //在fragment获取activity中的控件
        TextView tv = getActivity().findViewById(R.id.tv_frag_main);
        tv.setText("main in fragment textview");
    }
}
